The context calculus cExtended

نویسندگان

  • Mirna Bognar
  • Roel de Vrijer
چکیده

ions over hole variables, hole lling simply boils down to (multiple) -reduction. So, in our running example we get ( h: x:x( h x)y)( x:x)! x:x( ( x:x) x)y. In the case of composition, the rewrite relation involves some shifting of abstractions. For example, let C x:2 and D x( y:2) be two -contexts. Then the composition of the two, here denoted by C D, results in the context x:x( y:2). Note that the hole of the result of the composition is the hole of the second context, which potentially binds variables x as well as y. In the context calculus, these contexts are represented as Cc h: x: h x and Dc g:x( y: g y). Because the second context is going to be put into the hole of Cc, it is provided with means of communication, adapted for this purpose: D0 c x: g:x( y: g xy). The composition puts the second context into the hole, and moves the g abstraction at the beginning of C, so that the whole is an abstraction over the second hole g, the hole of D. The composition rewrite step should result in Cc D0 c! g: x: ( x:x( y: g xy)) x. This is an instance of the composition rewrite rule: ( h:U ) ( u1:::un: g:V ) ! g:U [[h := u1:::un:V ]] where g is shifted to the beginning of the reduct. Note that by performing the ensuing communication step this term reduces to g: x:x( y: g xy), which is a representation of the resulting composition in lambda calculus. Framework. In the context calculus the building blocks can freely be combined to form c-terms: variables, abstractions, applications and compositions. If a context contains many occurrences of a hole, these may be given the same name, like in for example the c-term h: x:( h x)( h x). All occurrences of the same hole should have the same number of arguments, though. If a context contains many holes, these can be represented by di erent hole variables, as in h: g: x:( 1 h x) ( y: 2 g xy). Note that here the holes are lled sequentially using the -rule. An alternative representation is h; g: x:( 1 h x) ( y: 2 g xy). Last but not least, the calculus may include variables over contexts and functions over contexts, witnessing the true rst-class treatment of contexts. Pretyping. The exibility of the framework can be controlled by `pretyping', restricting the c-term formation. The aim of these restrictions is to gain more control over the form of c-terms. Pretyping works in c like typing does in lambda calculus. In a typed lambda calculus, each variable has a type and term formation is led by a set of typing rules. Analogously, a set of pretyping rules controls the c-term formation. By means of pretyping, c-terms can be restricted to representations of contexts with only one hole, or variables in abstractions can be ensured to match their arguments, for example. 4 De nition of c This section contains the de nition of the (untyped) framework. In the absence of pretyping, which naturally controls term-formation, a couple of assumptions are made about composition by using labelled composition constructors and composition rewrite rules of special form. With pretyping de ned, such assumptions can in general be enforced by the pretyping rules. Preliminary to the de nition of c-terms, the forms of composition that are allowed need to be speci ed. This can be accomplished by labeling each composition constructor 5 with an index 2 I. We do not specify the precise form of the indices, but here only assume the existence of the following functions de ned on I. First Ar( ), which returns the number of holes of the outer context involved in composition. Secondly Ind( ), which speci es whether contexts are represented as or -abstractions, or as a sequence of such abstractions. Thirdly Ncom( ), which speci es (the cardinality of) the communication between the holes of the main context and corresponding communicating contexts. Note by the way that in many cases, depending on the pretyping, composition will be de nable. Let V be a countably in nite set of variables. De nition 4.1 ( c) The set of un(pre)typed c-terms c is de ned inductively by U ::= u j ( u:U) j (U U) j ( nu1; :::; un:U) j ( n U U:::U ) j ( (U;U; :::; U ) where u 2 V, 2 I, U; :::; U abbreviates n U 's and Ar( ) = n+ 1. Notation. Variables u1; :::; un in ( nu1; :::; un:U) will be abbreviated by ~u, and n terms U1:::Un in the expressions ( n U U1:::Un) and ( (U;U1; :::; Un) will be abbreviated by ~ U , where the vectors are empty if n = 0. We will even omit the indices n and and assume that the arities of , and and the number of their arguments match. Furthermore, if is binary, it is used in in x notation. As usual, standard abbreviations regarding brackets apply. In the remainder, the following convention considering typical elements will be maintained (if not explicitly stated otherwise): i; j; k;m; n 2 IN, u; u0; ui; v; w; ::: 2 V and U;U 0; Ui; V;W::: 2 c. The multiple abstractors n and the multiple applicators m are generalised forms of the familiar (simple) abstractor and applicator. The free and bound variables in a c-term are de ned as in lambda calculus. As in the case of lambda calculus, c-terms are considered equal up to -conversion. Moreover, we assume that bound variables are renamed whenever necessary. In c, we need multiple substitutions, which are a straightforward pointwise extension of (single) substitutions. For U; ~ V 2 c and n distinct variables ~v, where n is also the number of terms in ~ V , the result U [[~v := ~ V ]] of substituting Vi for free occurrences of vi in U (1 i n) is de ned as: u[[~v := ~ V ]] = Vi : if u = vi for some 1 i n u : otherwise , (B~u:U 0)[[~v := ~ V ]] = B~u:(U 0[[~v := ~ V ]]), F (U 0; U1:::Um)[[~v := ~ V ]] = F (U 0[[~v := ~ V ]]; U1 [[~v := ~ V ]] :::Um[[~v := ~ V ]]). Here B: denotes or , and F (; ) denotes , or . Before giving the de nition of c, an important assumption about the collection of the composition rules is explained. We assume that the arguments of the composition are of the right shape in the following sense. Suppose contexts are represented as sequences of multiple abstractions, for example u1u2: u3:U is a representation of some context. If it is the outer context in a composition, the composition should have another three arguments that are communicating contexts represented in the same way: as sequences of multiple abstractions, e.g., (( u1u2: u3:U); ( ~u 0: ~u 00:U 0); ( ~v: ~v 0:V ); ( ~ w: ~ w 0:W )). Moreover, the way the hole variables are grouped by the multiple binders should be preserved, so the composition should reduce to ~u 00~v 0: ~ w 0:U [[u1 := ~u 0:U 0; u2 := ~v:V ; u3 := ~ w:W ]], 6 where the holes ~u 00 and ~v 0 are now under the same multiple abstractor because u1 and u2 were. It is assumed that all composition rules satisfy these conditions. De nition 4.2 (Context calculus c) The context calculus c is de ned on terms of c with rewrite relations induced by the following rule schemes: ( u:U ) V ! U [[u := V ]] ( ) ( ~u:U) ~ V ! U [[~u := ~ V ]] ( ) In addition to these rule schemes, countably many composition rule schemes having the following form are allowed: ((~B~u:U ); ( ~v:~B~v 0:V1); :::; ( ~ w:~B~ w 0:Vn)) ! ~B~v 0; :::; ~ w 0:U [[u1 := ~v:V1; :::; un := ~ w:Vn]] ( ) where ~B~u:U stands for ~u:U or u1:::ui: ui+1:::: uj :::un:U with u1:::uiui+1:::uj :::un = ~u. Remark. The context calculus can be de ned more e ciently as follows. Since hole lling and compositions are functions on contexts and terms, they can be de ned as c-terms, provided a powerful enough pretyping system (in the case of last example, let comp cd0: g0:c( x0:( d0 x0)g0)). Furthermore, by encoding the single abstraction and single application as special cases of the corresponding multiple one, the only constructors that are really needed are and and the rule ( ). Finally, we only mention the main result of c. Theorem 4.3 c is con uent. The proof is done indirectly via higher-order rewriting systems (HRSs), a framework for term rewriting systems with binders. Since the context calculus is such a rewriting system, it can very naturally be written as a HRS. The proof is conducted in a couple of stages. Firstly, the higher-order system H is de ned, by translating the constructors and rewrite schemes of the context calculus. The higher-order system H turns out to be orthogonal (there are no critical pairs and all rules are left-linear (i.e. free variables occur at most once on the left-hand side of a rule)). Since, by a general theorem, any orthogonal HRS is con uent, it follows that H is con uent. Next, H is restricted to a subsystem, called H c, which is closed under reduction and which corresponds to the context calculus. From the properties of H and the theory of HRSs, it can be shown that H c is con uent, hence the context calculus too. A full version of the proof can be found at http://www.cs.vu.nl/~mirna/conproof.ps. 5 An example of pretyping The pretyped calculus c! given in this section describes the simply typed lambda calculus with contexts (i) with many holes, which may occur manifold, (ii) where holes are lled sequentially, (iii) including composition and (iv) including context variables and functions over (representations of) contexts. The pretyping rules of c! generally follow the typing rules of the calculus of Hashimoto and Ohori (cf. [HO98]). In this section, we will rst de ne the pretypes, the pretyping rules and the calculus c!. Then, we will 7 (var) (x : ) 2 ; ` x : (hvar) (h : [~ ] ) 2 ; ` ~ V : ~ ; ` h ~ V : (abs) ; x : ; ` U : 0 ; ` x : :U : ! 0 (habs) ; ; h : [~ ] ` U : 0 ; ` h : [~ ] :U : [~ ] ) 0 (app) ; ` U : ! 0 ; ` V : ; ` U V : 0 (mabs) ; ~x : ~ ; ` U : ; ` ~x : ~ :U : [~ ] (mapp) ; ` U : [~ ] ; ` ~ V : ~ ; ` U ~ V : (fill) ; ` U : [~ ] ) 0 ; ` V : [~ ] ; ` U V : 0 Figure 1: Pretyping rules for c! summarize some properties of c! and brie y compare c! to the calculus of Hashimoto and Ohori [HO98]. Finally, we will name two variations of this pretyping. If BT denotes the set of base types with a 2 BT , then the -pretypes ( 2 T ) and the -pretypes ( 2 P) are de ned as ::= a j ! j [~ ] ) and ::= j [~ ] . Here, ! and ) associate to the right, ! binds stronger than [ ] and [ ] binds stronger than ). The -pretypes are used for pretyping terms and contexts, and the -pretypes are also used for pretyping communicating objects and holes. The pretyping uses two bases, the basis containing declarations of the form x : , and the basis containing declarations of the form h : [~ ] . The bases are split because the elements of are used as true variables and the elements of as markers, in the sense that they are used for marking the beginning (abstraction) and endings (i.e. holes) of a context. The new type constructors [ ] and ) are introduced for better correspondence with the constructors of c (namely, [ ] for and ) and for distinguishing between two kinds of abstractions: over term or context variables, and over hole variables (! versus)), as will become clear in the pretyping rules. In the pretyping rules, ~ U : ~ denotes the pointwise pretyping Ui : i for 1 i j~ j, and both and are, without loss of generality, assumed to contain distinct variables. De nition 5.1 (Pretyping rules for c!) A term U 2 c is pretypable by from the bases ; , if ; ` U : can be derived using the pretyping rules displayed in Figure 1. We comment on the rules shortly. The rules (var), (abs) and (app) are the familiar Church style typing rules for !. The rules (hvar), (habs) and (fill) are their respective counterparts for the hole variables. By the rule (hvar), hole variables are immediately provided with communication, generalizing the interface technique in the type system in [HO98]. Note that a plain hole variable is not pretypable. However, the more general rule, ; ` h : [~ ] if (h : [~ ] ) 2 , is also posssible in our setting. The rule (fill) is actually an application rule. An alternative understanding of the rules (habs) and (fill) is that the (simple) abstractor and applicator are duplicated in order to distinguish between abstractions over term or context variables and abstractions over hole variables, 8 (x : a) 2 fz : a; x : ag(h : [a]a) 2 fh : [a]ag z : a; x : a;h : [a]a ` x : a(z : a) 2 fz : agz : a; x : a;h : [a]a ` h x : a (h : [a]a) 2 fh : [a]ag z : a;h : [a]a ` z : az : a;h : [a]a ` x : a: h x : a! a z : a;h : [a]a ` h z : az : a;h : [a]a ` ( x : a: h x)( h z) : az : a ` h : [a]a:( x : a: h x)( h z) : [a]a) aFigure 2: An example of pretyping in c!and the corresponding applications. The rules (mabs) and (mapp) are added for pretypingcommunication. By the rule (mabs) no hole variables may occur in a communication.Note that there is no composition in the pretyping rules. This is because composition isde nable within c!: for every (context) U of pretype [~ ] ) 0 and every (communicatingcontext) V of pretype [~ ]([~ ] ) ) the following closed pretypable c-term can act as acomposition constructor in comp U V ,comp c : [~ ] ) 0: d : [~ ]([~ ] ) ): g[~ ] :c ( ~u : ~ :( d ~u) ( ~v : ~ : g ~v)): ([~ ] ) 0)! ([~ ]([~ ] ) )) ([~ ] ) 0)).Consequently, the composition constructor, rewrite rule and pretyping rule are omittedfrom c!.Figure 2 is an example of pretyping in c!.De nition 5.2 ( c!) The terms of c! are the well-pretyped terms of c according toDe nition 5.1. The rewrite rules are the rules ( ) and ( ) of c, now over well-pretypedterms.We have the following results.Proposition 5.3 (Uniqueness of pretypes) If ; ` U : 1 and ; ` U : 2 then12.Proposition 5.4 (Subject reduction) If ; ` U : and U ! V , then ; ` V : .Proposition 5.5 (Strong normalization) Reduction in c! is strongly normalizing.The proofs of the rst two propositions are the standard ones, as in the case of ! ala Church. The proof of the second proposition uses counterparts of the generation lemmaand the substitution lemma. Note that, because of the choice of the rule (hvar), the subjectreduction property does not hold for a multiple version of -rule, e.g. ~u : ~ : h ~u ! hand h is not pretypable. The proof of strong normalization can be done via the naturaltranslation of c! into !.The example described in this section extends the work of Hashimoto and Ohori [HO98].It includes multiple occurrences of a hole and drops their condition on the -rule, by which-reduction is not allowed within (representations of) contexts. Moreover, c! allowscomposition, which is not present in their system.We conclude by mentioning two simple variations of this example of pretyping, whichcan even be combined. These variations illustrate the expressive power of the frameworkc, which results from the possibility of ne-tuning the pretyping rules.9 Untyped -contexts. Let BT contain only one pretype constant t, consider -pretypesmodulo t = t! t, and add a rule by which if ; ` U : then ; ` U : 0 for = 0.Such a pretyping describes the untyped lambda calculus with the same kind of contextsas c!, which again has the subject reduction property (the uniqueness of pretyping andstrong normalization are lost, as expected). For example, according to this pretyping,z : t ` h : [t] t :( x : t: h x)( h z) : [t]t ) t and ` ( x : t:xx)( x : t:xx) : t.This pretyping essentially has the e ect of rules for well-formedness of untyped -termsand of typing rules on the contexts and holes, by ignoring the type constructor !.-contexts with one hole. As contexts \with one hole" we consider those which trans-late to c-terms where each subterm has at most one free hole variable. Such contextscan be captured by imposing extra conditions on . The conditions involve leavingout (but keeping h if present, in the rules (var), (habs) and (fill)) or splitting of thepost-condition into a nite union of i's (not necessarily disjoint) that are used by thepre-conditions (in the rules (app) and (mapp)), and in all cases, allowing ('s) to containat most one element (in the rules (hvar), (abs), (app), (mabs) and (mapp)). These condi-tions restrain the pretyping of terms that can act as composition constructors, which seemto have a subterm with two free variables of -pretypes; for instance d and g in the sub-term ( d ~u) ( ~v : ~ : g ~v) of the c!-term comp given above. Therefore, a compositionconstructor , and the following composition pretyping rule and composition rewrite ruleare added; ` U : [~ ] ) 0 ; ` V : [~ ]([~ ] ) ); ` U V : [~ ] ) 0(comp)( h : [~ ] :U) ( ~u : ~ : g : [~ ] :V ) ! g : [~ ] :U [[h := ~u : ~ :V ]]( )The composition pretyping rule resembles the composition on functions: if V : A ! Band U : B ! C then U V : A ! C with A;Band C0. In this rule,communication is added, pretyped by [~ ] and [~ ], which `move' through the pretypesfollowing the movement of the corresponding abstractions in the composition rewrite rule.Even with the additional composition pretyping rule and rewrite rule, in the calculusobtained by such pretyping the properties of uniqueness of pretyping, subject reductionand strong normalization are preserved.AcknowledgementsWe would like to thank Vincent van Oostrom for suggesting several improvements.References[Bal87] Herman Balsters. Lambda calculus extended with segments. In Mathematical logic andtheoretical computer science (College Park, Md., 1984{1985), pages 15{27. Dekker, NewYork, 1987.[Bal94] H. Balsters. Lambda calculus extended with segments: Chapter 1, Sections 1.1 and 1.2(Introduction). In R. P. Nederpelt, J. H. Geuvers, and R. C. de Vrijer, editors, Selectedpapers on Automath, pages 339{367. North-Holland, Amsterdam, 1994.[Bar84] H.P. Barendregt. The Lambda Calculus, its Syntax and Semantics, volume 103 of Studiesin Logic and the Foundations of Mathematics. North-Holland Publishing Company,revised edition, 1984. (Second printing 1985).10 [Bru78] N.G. de Bruijn. A namefree lambda calculus with facilities for internal de nition ofexpressions and segments. Technical Report 78-WSK-03, Technological University Eind-hoven, 1978.[BV99] Mirna Bognar and Roel de Vrijer. Segments in the context of contexts. Preprint, VrijeUniversiteit Amsterdam, 1999.[DPS97] Joelle Despeyroux, Frank Pfenning, and Carsten Schurmann. Primitive recursion forhigher-order abstract syntax. In Typed lambda calculi and applications (Nancy, 1997),pages 147{163. Springer, Berlin, 1997.[HO98] Masatomo Hashimoto and Atsushi Ohori.A typed context calculus.Surikaisekikenkyusho K okyuroku, (1023):76{91, 1998. Type theory and its appli-cation to computer systems (Japanese) (Kyoto, 1997).[KKM99] Michael Kohlhase, Susanna Kuschert, and Martin Muller. Dynamic lambda calculus.Preprint, available at http://www.ags.uni-sb.de/~kohlhase, 1999.[NGV94] R. P. Nederpelt, J. H. Geuvers, and R. C. de Vrijer. Selected Papers on Automath,volume 133 of Studies in Logic and the Foundations of Mathematics. North-Holland,Amsterdam, 1994.[Nip93] T. Nipkow. Orthogonal Higher-Order Rewrite Systems are Con uent. In Proceedings ofthe International Conference on Typed Lambda Calculi and Application, pages 306{317,1993.[OR93] V. van Oostrom and F. van Raamsdonk. Comparing combinatory reduction systemsand higher-order rewrite systems. Technical Report CS-R9361, CWI, 1993. Extendedabstract in Proceedings of HOA'93.[PE88] F. Pfenning and C. Elliott. Higher-order abstract syntax. In Proceedings of the SIG-PLAN'88 Conference on Programming Language Design and Implementation, pages199{208. ACM Press, 1988.[San98] David Sands. Computing with contexts, a simple approach. Electronic Notes in Theo-retical Computer Science, 10, 1998.[SSB99] M. Sato, T. Sakurai, and R. Burstall. Explicit environments. In Jean-Yves Girard,editor, Proceedings of the 4th International Conference on Typed Lambda Calculi andApplication, pages 340{354, 1999.[Tal91] C. L. Talcott. Binding structures. In Vladimir Lifschitz, editor, Arti cial Intelligenceand Mathematical Theory of Computation. Academic Press, 1991.11

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Homotopy approximation of modules

Deleanu, Frei, and Hilton have developed the notion of generalized Adams completion in a categorical context. In this paper, we have obtained the Postnikov-like approximation of a module, with the help of a suitable set of morphisms.

متن کامل

An analytic study on the Euler-Lagrange equation arising in calculus of variations

The Euler-Lagrange equation plays an important role in the minimization problems of the calculus of variations. This paper employs the differential transformation method (DTM) for finding the solution of the Euler-Lagrange equation which arise from problems of calculus of variations. DTM provides an analytical solution in the form of an infinite power series with easily computable components. S...

متن کامل

On certain fractional calculus operators involving generalized Mittag-Leffler function

The object of this paper is to establish certain generalized fractional integration and differentiation involving generalized Mittag-Leffler function defined by Salim and Faraj [25]. The considered generalized fractional calculus operators contain the Appell's function $F_3$ [2, p.224] as kernel and are introduced by Saigo and Maeda [23]. The Marichev-Saigo-Maeda fractional calculus operators a...

متن کامل

NON-POLYNOMIAL SPLINE FOR THE NUMERICAL SOLUTION OF PROBLEMS IN CALCULUS OF VARIATIONS

A Class of new methods based on a septic non-polynomial spline function for the numerical solution of problems in calculus of variations is presented. The local truncation errors and the methods of order 2th, 4th, 6th, 8th, 10th, and 12th, are obtained. The inverse of some band matrixes are obtained which are required in proving the convergence analysis of the presented method. Convergence anal...

متن کامل

Certain subclass of $p$-valent meromorphic Bazilevi'{c} functions defined by fractional $q$-calculus operators

The aim of the present paper is to introduce and investigate a new subclass of Bazilevi'{c} functions in the punctured unit disk $mathcal{U}^*$ which have been described through using of the well-known fractional $q$-calculus operators, Hadamard product and a linear operator. In addition, we obtain some sufficient conditions for the func...

متن کامل

Non-Newtonian Fuzzy numbers and related applications

Although there are many excellent ways presenting the principle of the classical calculus, the novel presentations probably leads most naturally to the development of the non-Newtonian calculus. The important point to note is that the non-Newtonian calculus is a self-contained system independent of any other system of calculus. Since this self-contained work is intended for a wide audience, inc...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1999